Hello, |
Re: layout column using skip list? Regards, Peter |
Re: layout column using skip list?
What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
// this function returns the special DXL layout code for fetching the
// memory address for the cache from sFileName and then get the text to display
// from the in memory skip list.
string colCode (string sFileName) {
// escape the filename, since we need to put it to DXL code
Buffer bufFile = create()
int i; for (i = 0; i < length sFileName; i++) {
if (sFileName[i] == '\\') bufFile += "\\"
bufFile += sFileName[i]
}
string sResult = "
noError()
// read the memory address from the file
Stream x = read \"" (stringOf bufFile) "\"
lastError()
// if the file exists we will get a Stream here
if (!null x) {
// read the memory address
int adSkip = 0
x >> adSkip
if (adSkip != 0) {
// get the Skip cache
Skip sk = addr_ adSkip
// look up the object in the skip, fetch the text and display it
int nr = obj.\"Absolute Number\"
string sDisplayVal = \"\"
if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
} else {
// now what?
}
} else {
// You might want to show some dummy text here, that the cache does not exist
}
"
delete bufFile
return sResult
}
// This is our cache. Key = AbsNo Value = string to display
Skip skBuffer = create()
// This is the file where we store the cache address
string sCacheFileName = tempFileName ()
// write the memory address of the skip to the temp file
Stream x = write sCacheFileName
x << ((addr_ skBuffer) int) ""
close x
// calculate our stuff, put it to the skip list ...
// key = absNo value = string to display
Object o; for o in current Module do {
int nr = o."Absolute Number"
// put your heavily calculated stuff here ...
put (skBuffer, nr, "This is object " nr "!!")
}
// Now lets insert a DXL Layout Column
Column c = insert column 0 // insert column
// Give it the code. You might want to give it a title maybe
dxl (c, colCode(sCacheFileName) )
// This is the GUI we are using to host the data cache
// As long as it is alive our cache will be valid
// Show a progressbar for long calculations, will you?
DB gui = centered "Calculating ... "
// When the user closes the GUI our cache will die.
// now we will delete the tempFile, so the layout DXL will not try to access the
// memory addresses anymore.
void onClose (DB x) {
deleteFile sCacheFileName
hide x
// delete the column, or let it show its dummy text
delete c
}
// close callback works very reliably.
close (gui, false, onClose)
// show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout
// column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
// tool to display cached DXL Layouts.
show gui
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: layout column using skip list? Mathias Mamsch - Wed Sep 26 16:26:48 EDT 2012
What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
// this function returns the special DXL layout code for fetching the
// memory address for the cache from sFileName and then get the text to display
// from the in memory skip list.
string colCode (string sFileName) {
// escape the filename, since we need to put it to DXL code
Buffer bufFile = create()
int i; for (i = 0; i < length sFileName; i++) {
if (sFileName[i] == '\\') bufFile += "\\"
bufFile += sFileName[i]
}
string sResult = "
noError()
// read the memory address from the file
Stream x = read \"" (stringOf bufFile) "\"
lastError()
// if the file exists we will get a Stream here
if (!null x) {
// read the memory address
int adSkip = 0
x >> adSkip
if (adSkip != 0) {
// get the Skip cache
Skip sk = addr_ adSkip
// look up the object in the skip, fetch the text and display it
int nr = obj.\"Absolute Number\"
string sDisplayVal = \"\"
if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
} else {
// now what?
}
} else {
// You might want to show some dummy text here, that the cache does not exist
}
"
delete bufFile
return sResult
}
// This is our cache. Key = AbsNo Value = string to display
Skip skBuffer = create()
// This is the file where we store the cache address
string sCacheFileName = tempFileName ()
// write the memory address of the skip to the temp file
Stream x = write sCacheFileName
x << ((addr_ skBuffer) int) ""
close x
// calculate our stuff, put it to the skip list ...
// key = absNo value = string to display
Object o; for o in current Module do {
int nr = o."Absolute Number"
// put your heavily calculated stuff here ...
put (skBuffer, nr, "This is object " nr "!!")
}
// Now lets insert a DXL Layout Column
Column c = insert column 0 // insert column
// Give it the code. You might want to give it a title maybe
dxl (c, colCode(sCacheFileName) )
// This is the GUI we are using to host the data cache
// As long as it is alive our cache will be valid
// Show a progressbar for long calculations, will you?
DB gui = centered "Calculating ... "
// When the user closes the GUI our cache will die.
// now we will delete the tempFile, so the layout DXL will not try to access the
// memory addresses anymore.
void onClose (DB x) {
deleteFile sCacheFileName
hide x
// delete the column, or let it show its dummy text
delete c
}
// close callback works very reliably.
close (gui, false, onClose)
// show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout
// column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
// tool to display cached DXL Layouts.
show gui
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
The other thing that I should have mentioned is, you can change the values in the skip list from the GUI. You could for example have a radio box to switch the column between a different display of informtion, or a refresh button, that recalculates the DXL layout. You can calculate the results from a timer to have background calculation, instead of calculating them all at once, blocking DOORS. This makes up for a very nice user experience. Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: layout column using skip list? Mathias Mamsch - Wed Sep 26 16:26:48 EDT 2012
What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
// this function returns the special DXL layout code for fetching the
// memory address for the cache from sFileName and then get the text to display
// from the in memory skip list.
string colCode (string sFileName) {
// escape the filename, since we need to put it to DXL code
Buffer bufFile = create()
int i; for (i = 0; i < length sFileName; i++) {
if (sFileName[i] == '\\') bufFile += "\\"
bufFile += sFileName[i]
}
string sResult = "
noError()
// read the memory address from the file
Stream x = read \"" (stringOf bufFile) "\"
lastError()
// if the file exists we will get a Stream here
if (!null x) {
// read the memory address
int adSkip = 0
x >> adSkip
if (adSkip != 0) {
// get the Skip cache
Skip sk = addr_ adSkip
// look up the object in the skip, fetch the text and display it
int nr = obj.\"Absolute Number\"
string sDisplayVal = \"\"
if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
} else {
// now what?
}
} else {
// You might want to show some dummy text here, that the cache does not exist
}
"
delete bufFile
return sResult
}
// This is our cache. Key = AbsNo Value = string to display
Skip skBuffer = create()
// This is the file where we store the cache address
string sCacheFileName = tempFileName ()
// write the memory address of the skip to the temp file
Stream x = write sCacheFileName
x << ((addr_ skBuffer) int) ""
close x
// calculate our stuff, put it to the skip list ...
// key = absNo value = string to display
Object o; for o in current Module do {
int nr = o."Absolute Number"
// put your heavily calculated stuff here ...
put (skBuffer, nr, "This is object " nr "!!")
}
// Now lets insert a DXL Layout Column
Column c = insert column 0 // insert column
// Give it the code. You might want to give it a title maybe
dxl (c, colCode(sCacheFileName) )
// This is the GUI we are using to host the data cache
// As long as it is alive our cache will be valid
// Show a progressbar for long calculations, will you?
DB gui = centered "Calculating ... "
// When the user closes the GUI our cache will die.
// now we will delete the tempFile, so the layout DXL will not try to access the
// memory addresses anymore.
void onClose (DB x) {
deleteFile sCacheFileName
hide x
// delete the column, or let it show its dummy text
delete c
}
// close callback works very reliably.
close (gui, false, onClose)
// show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout
// column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
// tool to display cached DXL Layouts.
show gui
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Mathias, I've tried your example but I wasn't able to make it run, I am quite new about DXL, so I beg your pardon... The main problem seems to be the passing of information between the sResult and the "normal" code, no way to see the bufFile variable inside the string code. Are there some "special" way to write the code that will be interpreted as text string (those inside the sResult?). I mean, we have to take into account any CR/LF or is it enough to put the \" escape char before any " character? I simplified as much as possible the code, the essential thing is the possibility to pass information to each view's object (the Skip List addr_ ). This is my snippet version:
string colCode1 (string sFileName) The call is done as: dxl (c, colCode1(sCacheFileName) ) The result is: -E- DXL: <Line:1> incorrectly concatenated tokens -E- DXL: <Line:1> incorrect arguments for function (display) -E- DXL: <Line:1> undeclared variable (bufFile) -I- DXL: all done with 3 errors and 0 warnings -I- DXL: execution halted
Any help will be appreciate! Thank you, Franco Burzio |
Re: layout column using skip list? Mathias Mamsch - Wed Sep 26 16:26:48 EDT 2012
What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
// this function returns the special DXL layout code for fetching the
// memory address for the cache from sFileName and then get the text to display
// from the in memory skip list.
string colCode (string sFileName) {
// escape the filename, since we need to put it to DXL code
Buffer bufFile = create()
int i; for (i = 0; i < length sFileName; i++) {
if (sFileName[i] == '\\') bufFile += "\\"
bufFile += sFileName[i]
}
string sResult = "
noError()
// read the memory address from the file
Stream x = read \"" (stringOf bufFile) "\"
lastError()
// if the file exists we will get a Stream here
if (!null x) {
// read the memory address
int adSkip = 0
x >> adSkip
if (adSkip != 0) {
// get the Skip cache
Skip sk = addr_ adSkip
// look up the object in the skip, fetch the text and display it
int nr = obj.\"Absolute Number\"
string sDisplayVal = \"\"
if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
} else {
// now what?
}
} else {
// You might want to show some dummy text here, that the cache does not exist
}
"
delete bufFile
return sResult
}
// This is our cache. Key = AbsNo Value = string to display
Skip skBuffer = create()
// This is the file where we store the cache address
string sCacheFileName = tempFileName ()
// write the memory address of the skip to the temp file
Stream x = write sCacheFileName
x << ((addr_ skBuffer) int) ""
close x
// calculate our stuff, put it to the skip list ...
// key = absNo value = string to display
Object o; for o in current Module do {
int nr = o."Absolute Number"
// put your heavily calculated stuff here ...
put (skBuffer, nr, "This is object " nr "!!")
}
// Now lets insert a DXL Layout Column
Column c = insert column 0 // insert column
// Give it the code. You might want to give it a title maybe
dxl (c, colCode(sCacheFileName) )
// This is the GUI we are using to host the data cache
// As long as it is alive our cache will be valid
// Show a progressbar for long calculations, will you?
DB gui = centered "Calculating ... "
// When the user closes the GUI our cache will die.
// now we will delete the tempFile, so the layout DXL will not try to access the
// memory addresses anymore.
void onClose (DB x) {
deleteFile sCacheFileName
hide x
// delete the column, or let it show its dummy text
delete c
}
// close callback works very reliably.
close (gui, false, onClose)
// show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout
// column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
// tool to display cached DXL Layouts.
show gui
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Mathias, I am quite new to DXL (so I beg your pardon...) and I wasn't able to make it run. I've tried to reduce to the following the solution to reduce any possible "noise"
string colCode1 (string sFileName) } dxl (c, colCode1(sCacheFileName) )
The main problem is the fact that bufFile is not recognised as a variable, so there is no way to pass info from the external to the code that will be send to the viwew's column via DXL(set) command. So if it isn't possible to pass the sCacheFileName the solution is not useful at all. This is what i've obtained: -E- DXL: <Line:1> incorrectly concatenated tokens -E- DXL: <Line:1> incorrect arguments for function (display) -E- DXL: <Line:1> undeclared variable (bufFile) -I- DXL: all done with 3 errors and 0 warnings -I- DXL: execution halted
Any help will be appreciate!! Franco Burzio
|
Re: layout column using skip list? Mathias Mamsch - Wed Sep 26 16:26:48 EDT 2012
What I did successfully is to calculate the results, and show a GUI to insert a special DXL layout column. As long as the GUI is on the screen the results will be valid in memory, so all we need to do is pass the skip list address to the DXL Layout column. In the below example I do this with a tempFile ... I have also done this successfully using a dynamic trigger on the module (manipulating the name of the trigger). So the DXL Layout column will just fetch the memory address of the skip list from the file (instead of the results itself). Then the data lookup goes lightening fast. See the below example code:
// this function returns the special DXL layout code for fetching the
// memory address for the cache from sFileName and then get the text to display
// from the in memory skip list.
string colCode (string sFileName) {
// escape the filename, since we need to put it to DXL code
Buffer bufFile = create()
int i; for (i = 0; i < length sFileName; i++) {
if (sFileName[i] == '\\') bufFile += "\\"
bufFile += sFileName[i]
}
string sResult = "
noError()
// read the memory address from the file
Stream x = read \"" (stringOf bufFile) "\"
lastError()
// if the file exists we will get a Stream here
if (!null x) {
// read the memory address
int adSkip = 0
x >> adSkip
if (adSkip != 0) {
// get the Skip cache
Skip sk = addr_ adSkip
// look up the object in the skip, fetch the text and display it
int nr = obj.\"Absolute Number\"
string sDisplayVal = \"\"
if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
} else {
// now what?
}
} else {
// You might want to show some dummy text here, that the cache does not exist
}
"
delete bufFile
return sResult
}
// This is our cache. Key = AbsNo Value = string to display
Skip skBuffer = create()
// This is the file where we store the cache address
string sCacheFileName = tempFileName ()
// write the memory address of the skip to the temp file
Stream x = write sCacheFileName
x << ((addr_ skBuffer) int) ""
close x
// calculate our stuff, put it to the skip list ...
// key = absNo value = string to display
Object o; for o in current Module do {
int nr = o."Absolute Number"
// put your heavily calculated stuff here ...
put (skBuffer, nr, "This is object " nr "!!")
}
// Now lets insert a DXL Layout Column
Column c = insert column 0 // insert column
// Give it the code. You might want to give it a title maybe
dxl (c, colCode(sCacheFileName) )
// This is the GUI we are using to host the data cache
// As long as it is alive our cache will be valid
// Show a progressbar for long calculations, will you?
DB gui = centered "Calculating ... "
// When the user closes the GUI our cache will die.
// now we will delete the tempFile, so the layout DXL will not try to access the
// memory addresses anymore.
void onClose (DB x) {
deleteFile sCacheFileName
hide x
// delete the column, or let it show its dummy text
delete c
}
// close callback works very reliably.
close (gui, false, onClose)
// show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout
// column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
// tool to display cached DXL Layouts.
show gui
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
Is there any benefit of reading and writing to a file for the memory address?
//https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014890784#77777777-0000-0000-0000-000014891453
// this function returns the special DXL layout code for fetching the
// memory address for the cache from sFileName and then get the text to display
// from the in memory skip list.
// This is our cache. Key = AbsNo Value = string to display
Skip skBuffer = create()
string literal (int x) {
if (x == ~0x7FFFFFFFFFFFFFFF) return "~0x7FFFFFFFFFFFFFFF";
Addr64_ ad = addr_ x; return ad ""
}
string codeString = "pragma runLim, 0
// read the memory address
int x = "literal(addr_ skBuffer)"
if (x != 0) {
// get the Skip cache
Skip sk = addr_ x
// look up the object in the skip, fetch the text and display it
int nr = obj.\"Absolute Number\"
string sDisplayVal = \"\"
if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
} else {
// now what?
}"
// calculate our stuff, put it to the skip list ...
// key = absNo value = string to display
Object o; for o in current Module do {
int nr = o."Absolute Number"
// put your heavily calculated stuff here ...
put (skBuffer, nr, "This is object " nr "!!")
}
// Now lets insert a DXL Layout Column
Column c = insert column 0 // insert column
// Give it the code. You might want to give it a title maybe
dxl (c, codeString)
// This is the GUI we are using to host the data cache
// As long as it is alive our cache will be valid
// Show a progressbar for long calculations, will you?
DB gui = centered "Calculating ... "
// When the user closes the GUI our cache will die.
// now we will delete the tempFile, so the layout DXL will not try to access the
// memory addresses anymore.
void onClose (DB x) {
hide x
// delete the column, or let it show its dummy text
delete c
}
// close callback works very reliably.
close (gui, false, onClose)
// show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout
// column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
// tool to display cached DXL Layouts.
show gui
|
Re: layout column using skip list? EHcnck - Tue Sep 26 09:43:28 EDT 2017 Is there any benefit of reading and writing to a file for the memory address?
//https://www.ibm.com/developerworks/community/forums/html/topic?id=77777777-0000-0000-0000-000014890784#77777777-0000-0000-0000-000014891453
// this function returns the special DXL layout code for fetching the
// memory address for the cache from sFileName and then get the text to display
// from the in memory skip list.
// This is our cache. Key = AbsNo Value = string to display
Skip skBuffer = create()
string literal (int x) {
if (x == ~0x7FFFFFFFFFFFFFFF) return "~0x7FFFFFFFFFFFFFFF";
Addr64_ ad = addr_ x; return ad ""
}
string codeString = "pragma runLim, 0
// read the memory address
int x = "literal(addr_ skBuffer)"
if (x != 0) {
// get the Skip cache
Skip sk = addr_ x
// look up the object in the skip, fetch the text and display it
int nr = obj.\"Absolute Number\"
string sDisplayVal = \"\"
if (find (sk, nr, sDisplayVal)) { display sDisplayVal }
} else {
// now what?
}"
// calculate our stuff, put it to the skip list ...
// key = absNo value = string to display
Object o; for o in current Module do {
int nr = o."Absolute Number"
// put your heavily calculated stuff here ...
put (skBuffer, nr, "This is object " nr "!!")
}
// Now lets insert a DXL Layout Column
Column c = insert column 0 // insert column
// Give it the code. You might want to give it a title maybe
dxl (c, codeString)
// This is the GUI we are using to host the data cache
// As long as it is alive our cache will be valid
// Show a progressbar for long calculations, will you?
DB gui = centered "Calculating ... "
// When the user closes the GUI our cache will die.
// now we will delete the tempFile, so the layout DXL will not try to access the
// memory addresses anymore.
void onClose (DB x) {
hide x
// delete the column, or let it show its dummy text
delete c
}
// close callback works very reliably.
close (gui, false, onClose)
// show some text in the GUI for the user to close the dialog box, until he does not need the DXL Layout
// column anymore. This makes up for a very nice user experience. We use a similar technique for our branch manager
// tool to display cached DXL Layouts.
show gui
Hmm ... Not really. It is easier to check if a file exists or not, rather than if a memory address is valid. Imagine someone storing the column inside a view. The next gui who loads the view will get a crash. If you use the file based approach it is likely that the file does not exist anymore and the layout Column can show some dummy text. Regards, Mathias |